<div class="pageContent">
    <form method="post" action="{:U($module_name.'/chumoney')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
        <div class="pageFormContent" layoutH="97">
            <input type="hidden" name="id" value="{$_GET['id']})" />
            <fieldset>
                <legend>
                    对账信息
                </legend>
                <dl>
                    <dt>
                        真实姓名：
                    </dt>
                    <dd>
                        {$vo.username}<input type="hidden" name="realname" value="{$vo.username}">
                    </dd>
                </dl>
                <dl>
                    <dt>
                        用户组{$vo['groupid']}：
                    </dt>
                    <dd>
                        <select name="groupid" class="combox">
                            <volist name="rlist" id="row">
                                <option value="{$row['id']}"
                                    <eq name="vo['groupid']" value="$row['id']">
                                        selected="selected"
                                    </eq>>{$row['name']}
                                </option>
                            </volist>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt>
                        充值金额：
                    </dt>
                    <dd>
                        <font color="red">
                            {$bankpay.moneyprice}
                        </font>
                        元				<input id="moneyprice" type='hidden' value="{$bankpay.moneyprice}" />
                    </dd>
                </dl>
                <dl>
                    <dt>
                        充值卡号：
                    </dt>
                    <dd>
                        {$bankpay.kahao} 
                    </dd>
                </dl>
                <dl>
                    <dt>
                        银行转账流水号：
                    </dt>
                    <dd>
                        {$bankpay.liushuisn} 
                    </dd>
                </dl>
            </fieldset>
            <fieldset>
                <legend>
                    授权码
                </legend>
                <dt>
                    操作员授权号：
                </dt>
                <dd>
                    <input type="text" name="auth.money_auth" class="required input-text" readonly='readonly'>
					<a lookupgroup="auth" href="{:U('Money/lookup',array('tn'=>'UserMoneyAuth','fn'=>'money_auth,money_passwd,amount,give','field'=>'money_auth,money_passwd,oedu,ctime,statu','where'=>myencode(array('statu'=>0),1)))}" class="btnLook" rel='444'>选择授权码</a>
                    <span class="info">选择</span>
                </dd>
                </dl>
                <dl>
                    <dt>
                        授权密码：
                    </dt>
                    <dd>
                        <input type="text" class="input-text" name="auth.money_passwd" value="" readonly='readonly'>
                    </dd>
                </dl>
                <dl>
                    <dt>
                        授权金额：
                    </dt>
                    <dd>
                        <input type="text" class="input-text" name="auth.amount" value="" readonly='readonly'> 元
                    </dd>
                </dl>
				
				         <dl>
                    <dt>
                        授权赠送 ：
                    </dt>
                    <dd>
                        <input type="text" class="input-text" name="auth.give" value="0" readonly='readonly'> BV
                    </dd>
                </dl>
            </fieldset>
            <fieldset>
                <legend>
                    预付款 （填写负数为减少） 
                </legend>
                <dl style="height:20px;">
                    <dt>
                        增加CV：
                    </dt>
                    <dd style="width:230px;">
						<input type="hidden" name="czmoney" id="czmoney" value="{$bankpay.moneyprice}"  />
                        <input type="text" size="12"  class='required input-text' id="amount" name="amount" value="{$bankpay.moneyprice}">
						元，赠送 <font id="givecv" color="red">0</font>元
                    </dd>
                </dl>
				 <dl style="height:20px;">
                    <dt>
                        先到账：
                    </dt>
                    <dd style="width:230px;">
                        <input type="text" size="12" class="input-text" id="shouqi" name="shouqi" value="0">元
                    </dd>
                </dl>
                <dl style="height:20px;">
                    <dt>
                        分成几期到账：
                    </dt>
                    <dd>
                        <input type="text" id="cvqishu" name="cvqishu" value="0" class="input-text" size="3" />&nbsp;期 ，每期到账 <font id='eachmoney' color="red">0</font> 元
						
                    </dd>
                </dl>
            </fieldset>
            <fieldset>
                <legend>
                    赠送账户 BV （填写负数为减少） 
                </legend>
                <dl style="height:20px;">
                    <dt>
                        增加BV帐户：
                    </dt>
                    <dd style="width:230px;">
                        <input type="text" class="input-text" size="6" id="give" name="give" value="0"><input type="hidden" name="eachoedu" id="eachoedu" />&nbsp;BV
                    </dd>
                </dl>
                <dl style="height:20px;">
                    <dt>
                        分成几期到账：
                    </dt>
                    <dd>
                        <input type="text" id="qishu" name="qishu" value="12" class="input-text" size="3" />&nbsp;期
                    </dd>
                </dl>
            </fieldset>
            <dl>
            <dl>
                <dt>
                    备注信息：
                </dt>
                <dd>
                    <input type="text" class="required input-text" name="bzvu" value=""/>
                    <br/>
                    进行扣款操作时必须填写备注信息<input type="hidden" name="userid" value="{$vo['id']}" /><input type="hidden" name="forward" value="{$_SERVER['HTTP_REFERER']}" />
                </dd>
            </dl>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                保存
                            </button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                取消
                            </button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script>
	$(function(){
		$("#cvqishu").blur(function(){
			setvalue();	
			var cvqishu = parseInt($(this).val());
			if(cvqishu>0){
				var amount = parseInt($("#amount").val());
				var shouqi = parseInt($("#shouqi").val());
				var eachmoney = ((amount-shouqi)/cvqishu).toFixed(2);						
			}else{
				var eachmoney = 0;
			}
			$("#eachmoney").html(eachmoney);
		});
		
		$("#amount").blur(function(){
			setvalue();	
			var amount = parseInt($(this).val());
			var moneyprice = parseInt($("#moneyprice").val());
			var shouqi = parseInt($("#shouqi").val());
			if (amount < moneyprice) {
				$(this).css("border-color", "red");
				alertMsg.error('增加CV金额不能小于充值金额：' + moneyprice + '元!');
				
			}
			else {
				$("#givecv").html(amount - moneyprice);
				var cvqishu = parseInt($("#cvqishu").val());
				if (cvqishu > 0) {
					var eachmoney = ((amount-shouqi)/cvqishu).toFixed(2);			
				}
				else {
					var eachmoney = 0;
				}
				$("#eachmoney").html(eachmoney);
			}
			 
		});
		
		$("#shouqi").blur(function(){	
			setvalue();	
			var cvqishu = parseInt($("#cvqishu").val());
			if(cvqishu>0){
				var amount = parseInt($("#amount").val());
				var shouqi = parseInt($(this).val());
				var eachmoney = ((amount-shouqi)/cvqishu);		
			}else{
				var eachmoney = 0;
			}
			$("#eachmoney").html(eachmoney);
		});
		
	});
	
	function setvalue(){
		if($("#shouqi").val() == ''){
			$("#shouqi").val(0); 
		}
		
		if($("#cvqishu").val() == ''){
			$("#cvqishu").val(0);
		}
	}
</script>